<template>
  <div>
    <h1>{{ $t("vr.mycollection") }}</h1>
    <ul class="infoUl">
      <li v-for="(v, i) in dataList" :key="i" @click="navTo(v)">
        <img class="imgBox" :src="v.picture" />
        <div class="txt">
          {{ v.title }}
        </div>
      </li>
    </ul>
    <el-dialog
      :visible.sync="dialogVisible"
      width="1000px"
      :before-close="handleClose"
    >
      <prod-detail :prodId="prodId" @handleClose="handleClose"></prod-detail>
    </el-dialog>
  </div>
</template>

<script>
import api from "servicePath/index"
import prodDetail from "@/views/foundation/common/prodDetail.vue"

import { mapState } from "vuex"
export default {
  components: {
    prodDetail
  },
  data () {
    return {
      dataList: [],
      dialogVisible: false,
      prodId: ""
    }
  },
  computed: {
    ...mapState(["lang"])
  },
  mounted () {
    this.productList()
  },
  methods: {
    handleClose () {
      this.dialogVisible = false
      this.prodId = ""
    },
    navTo (i) {
      if (i.type == "2") {
        window.open(i.url)
      } else if (i.type == "1") {
        // this.$router.push({
        //   path: "/foundation/pc/home",
        //   query: {
        //     prodId: i.anchor
        //   }
        // })
        if (this.$store.state.userInfo !== "") {
          this.dialogVisible = true
          this.prodId = i.anchor
          //  this.$router.replace(`/foundation/pc/home?prodId=${anchor}`)
        } else {
          this.isShowLogin("show")
        }
      }
    },
    async productList () {
      const params = { type: "" }
      const res = await api.getProductList(params, this.lang)
      this.dataList = res.data
      console.log(res)
    }
  },
  watch: {
    "$store.state.lang": function () {
      this.productList()
    }
  }
};
</script>

<style lang="scss" scoped>
h1 {
  margin-bottom: 30px;
}
.infoUl {
  width: 100%;
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  flex-wrap: wrap;
  li {
    width: 48%;
    background: #fff;
    border-radius: 6px;
    border: none;
    -moz-box-shadow: 1px 1px 14px 5px #f0f0f0;
    -webkit-box-shadow: 1px 1px 14px 5px #f0f0f0;
    box-shadow: 1px 1px 14px 5px #f0f0f0;
    padding: 18px 15px;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    position: relative;
    .imgBox {
      width: 100px;
      height: 60px;
      // background-position: center;
      // background-size: cover;
      // background-repeat: no-repeat;
      margin-right: 10px;
      object-position: center;
      object-fit: contain;
    }
    .txt {
      width: 65%;
      height: 60px;
      display: flex;
      flex-direction: column;
      justify-content: center;
      padding: 10px 0;
    }
    .ico {
      width: 40px;
      position: absolute;
      right: 5%;
      top: 33%;
    }
  }
}
.btn {
  background: linear-gradient(to right, #ff7f41, #e6007e);
  width: 70%;
  padding: 15px;
  font-size: 14px;
  color: #fff;
  text-align: center;
  border: none;
  border-radius: 6px;
  outline: none;
  cursor: pointer;
}
</style>
